<!DOCTYPE html>
<html lang="en">
<head>
<title><#:C('sitename')#>--代理商平台</title>
<meta name="keywords" content="<#:C('keyword')#>"/>
<meta name="description" content="<#:C('content')#>"/>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<include file="Pub:Css"/>
</head>
<body>
<include file="Pub:top"/>
<include file="Pub:Nav"/>
<!--main-container-part-->
<div id="content">
  <!--breadcrumbs-->
  <div id="content-header">
    <div id="breadcrumb"> <a href="<#:U('index/index')#>" title="返回首页" class="tip-bottom"><i class="icon-home"></i>首页</a></div>
  </div>
  <!--End-breadcrumbs-->
  <div class="container-fluid" >
      <div class="widget-box widget-plain">
      <div class="center">
        <ul class="stat-boxes2">
          <li>
            <div class="left peity_bar_neutral"><span><span style="display: none;">2,4,9,7,12,10,12</span>
              <canvas width="50" height="24"></canvas>
              </span></div>
            <div class="right"> <strong id="sumauth">0</strong> 流量统计 </div>
          </li>
          <li>
            <div class="left peity_line_neutral"><span><span style="display: none;">10,15,8,14,13,10,10,15</span>
              <canvas width="50" height="24"></canvas>
              </span></div>
            <div class="right"> <strong  id="sumuser">0</strong>新增用户 </div>
          </li>
          <li>
            <div class="left peity_bar_bad"><span><span style="display: none;">3,5,6,16,8,10,6</span>
              <canvas width="50" height="24"></canvas>
              </span></div>
            <div class="right"> <strong id="sumshopad">0</strong> 商户广告统计</div>
          </li>
          <li>
            <div class="left peity_line_good"><span><span style="display: none;">12,6,9,23,14,10,17</span>
              <canvas width="50" height="24"></canvas>
              </span></div>
            <div class="right"> <strong id="sumpushad">0</strong> 投放广告统计</div>
          </li>
         
        </ul>
      </div>
    </div>
  <div class="row-fluid">
      <div class="span6">
        <div class="widget-box">
          <div class="widget-title"> <span class="icon"> <i class="icon-signal"></i> </span>
            <h5>流量统计</h5>
          </div>
          <div class="widget-content">
            <div class="chart" id="authchart"></div>
          </div>
        </div>
      </div>
      <div class="span6">
        <div class="widget-box">
          <div class="widget-title"> <span class="icon"> <i class="icon-signal"></i> </span>
            <h5>用户统计</h5>
          </div>
          <div class="widget-content">
            <div class="chart" id="userchart"></div>
          </div>
        </div>
      </div>
    </div>
    <div class="row-fluid">
      <div class="span6">
        <div class="widget-box">
          <div class="widget-title"> <span class="icon"> <i class="icon-signal"></i> </span>
            <h5>商户广告统计</h5>
          </div>
          <div class="widget-content">
            <div class="chart" id="shopchart"></div>
          </div>
        </div>
      </div>
      <div class="span6">
        <div class="widget-box">
          <div class="widget-title"> <span class="icon"> <i class="icon-signal"></i> </span>
            <h5>推送广告统计</h5>
          </div>
          <div class="widget-content">
            <div class="chart" id="pushchart"></div>
          </div>
        </div>
      </div>
    </div>

  </div>
</div>

<script src="<#$Theme['P']['root']#>/matrix/js/jquery.ui.custom.js"></script> 
<script src="<#$Theme['P']['root']#>/matrix/js/bootstrap.min.js"></script> 
<script src="<#$Theme['P']['root']#>/matrix/js/matrix.js"></script> 
<script src="<#$Theme['P']['js']#>/flot/jquery.flot.js"></script> 
<script src="<#$Theme['P']['root']#>/matrix/js/jquery.peity.min.js"></script> 
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="<#$Theme['P']['js']#>/flot/excanvas.min.js"></script><![endif]-->  
<script>


maruti = {
		// === Peity charts === //
		peity: function(){		
			$.fn.peity.defaults.line = {
				strokeWidth: 1,
				delimeter: ",",
				height: 24,
				max: null,
				min: 0,
				width: 50
			};
			$.fn.peity.defaults.bar = {
				delimeter: ",",
				height: 24,
				max: null,
				min: 0,
				width: 50
			};
			$(".peity_line_good span").peity("line", {
				colour: "#57a532",
				strokeColour: "#459D1C"
			});
			$(".peity_line_bad span").peity("line", {
				colour: "#FFC4C7",
				strokeColour: "#BA1E20"
			});	
			$(".peity_line_neutral span").peity("line", {
				colour: "#CCCCCC",
				strokeColour: "#757575"
			});
			$(".peity_bar_good span").peity("bar", {
				colour: "#459D1C"
			});
			$(".peity_bar_bad span").peity("bar", {
				colour: "#BA1E20"
			});	
			$(".peity_bar_neutral span").peity("bar", {
				colour: "#4fb9f0"
			});
		},

		// === Tooltip for flot charts === //
		flot_tooltip: function(x, y, contents) {
			
			$('<div id="tooltip">' + contents + '</div>').css( {
				top: y + 5,
				left: x + 5
			}).appendTo("body").fadeIn(200);
		}
}
var hourlist=[];
for(var i=0;i<24;i++){
	if(i<10){
		hourlist.push(["0"+i,i+"点"]);
	}else{
		hourlist.push([i,i+"点"]);
	}
}
function ct_ad(data){
	var sum=0;
	for(var vo in data){
		sum+=parseFloat( data[vo].showup);
	}
	$("#sumpushad").text(sum);
}
function ct_shopad(data){
	var sum=0;
	for(var vo in data){
		sum+=parseFloat( data[vo].showup);
	}
	$("#sumshopad").text(sum);
}
function init_chart(data){
	var bt=[];
	var bt_reg=[];
	var bt_phone=[];
	var bt_log=[];
	var bt_key=[];
	data=eval(data)  ;
	for(var vo in data){
		bt.push([data[vo].t,data[vo].ct]);
		bt_reg.push([data[vo].t,data[vo].ct_reg]);
		bt_phone.push([data[vo].t,data[vo].ct_phone]);
		bt_key.push([data[vo].t,data[vo].ct_key]);
		bt_log.push([data[vo].t,data[vo].ct_log]);
	}
	var ds=[{label:"总数",data:bt},{label:"注册认证",data:bt_reg},{label:"手机认证",data:bt_phone},{label:"一键上网",data:bt_key},{label:"帐号登录",data:bt_log},];
	$.plot($("#authchart"), ds, {grid: { hoverable: true, clickable: true, borderColor:'#000',borderWidth:1},xaxis:{ticks:hourlist},series:{lines:{fill:true, show: true}, points:{show: true,}}});
	ct_auth(data);
}

function ct_auth(data){
	var sum=0;
	for(var vo in data){
		sum+=parseFloat( data[vo].ct);
	}
	$("#sumauth").text(sum);
}
function ct_user(data){
	var sum=0;
	for(var vo in data){
		sum+=parseFloat( data[vo].totalcount);
	}
	$("#sumuser").text(sum);
}

function authchart(authurl){
		  $.ajax({
			  url: authurl,
		        type: "get",
				data:{
					'mode':'today'
					},
				dataType:'json',
				success:function(data){
					init_chart(data);
				}
			  });
	  	  
}

function shopad(authurl){
	$.ajax({
			  url: authurl,
		        type: "get",
				data:{
					'mode':'today'
					},
				dataType:'json',
				success:function(data){
						var bt=[];
						var bt_hit=[];
						data=eval(data);
						for(var vo in data){
							
							bt.push([data[vo].t,data[vo].showup]);
							bt_hit.push([data[vo].t,data[vo].hit]);
						}
						var dataset=[{label:"广告展示",data:bt},{label:"广告点击",data:bt_hit}];
						 $.plot($("#shopchart"), dataset, {grid: { hoverable: true, clickable: true, borderColor:'#000',borderWidth:1},xaxis:{ticks:hourlist},series:{lines:{fill:true, show: true}, points:  { show: true,}}});
							ct_shopad(data);
				}
			  });
}
function adchar(charurl){
	$.ajax({ url: charurl,
			        type: "get",
					data:{
						'mode':'today'
						
						},
					dataType:'json',
				
					success:function(data){
							var bt=[];
							var bt_hit=[];
							data=eval(data);
							for(var vo in data){
								
								bt.push([data[vo].t,data[vo].showup]);
								bt_hit.push([data[vo].t,data[vo].hit]);
							}
							var dataset=[{label:"广告展示",data:bt},{label:"广告点击",data:bt_hit}];
							 $.plot($("#pushchart"), dataset, {grid: { hoverable: true, clickable: true, borderColor:'#000',borderWidth:1},xaxis:{ticks:hourlist},series:{lines:{fill:true, show: true}, points:{ show: true,}}});
							
								ct_ad(data);
					}
				  });
}
function mchart(authurl){
	$.ajax({
		  url: authurl,
	        type: "get",
			data:{
				'mode':'today'
				
				},
			dataType:'json',
			success:function(data){
					data=eval(data);
					var bt_total=[];
					var bt_reg=[];
					var bt_phone=[];
					data=eval(data);
					for(var vo in data){
						bt_total.push([data[vo].t,data[vo].totalcount]);
						bt_reg.push([data[vo].t,data[vo].regcount]);
						bt_phone.push([data[vo].t,data[vo].phonecount]);
					}
					var dataset=[{label:"注册总人数",data:bt_total},{label:"帐号注册",data:bt_reg},{label:"手机注册",data:bt_phone}];
					$.plot($("#userchart"), dataset, {grid: { hoverable: true, clickable: true, borderColor:'#000',borderWidth:1},xaxis:{ticks:hourlist},series:{lines:{fill:true, show: true}, points:{ show: true,}}});
				ct_user(data);	
			}
		  });
}
$(function(){
	
	
		authchart('<#:U('index/getauthrpt')#>');
		shopad('<#:U('admanage/adrpt')#>');
		mchart('<#:U('index/getuserchart')#>');
	
		adchar('<#:U('pushadv/rpt')#>');
		
	
	//
	maruti.peity();

});
</script>

</body>
</html>
